package com.xpj.controller;

import com.xpj.annotation.RequestLimiter;
import com.xpj.service.AsyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
public class TestController {

    @GetMapping("/add")
    @RequestLimiter(name = "TestController.add", token = 1)
    public String add(){

        return "add";
    }

    @GetMapping("/find")
    @RequestLimiter(name = "TestController.find", token = 1)
    public String find(){

        return "find";
    }

    @Autowired
    private AsyncService asyncService;

    @GetMapping("/complex")
    public String complex(){
        System.out.println("1");
        asyncService.asyncSendMail();
        System.out.println("3");
        return "complex";
    }
}
